#include "Quad.h"
#include  "Entity2D.h"
#include "Renderer.h"
#include <d3dx9.h>
using namespace pg1;
Quad::Quad() :
Entity2D(),
tg_Vertices(new ColorVertex[4])
{

	tg_Vertices[0].x = -0.5; tg_Vertices[0].y = 0.5;	tg_Vertices[0].z = 0.0f;
	tg_Vertices[1].x = 0.5;  tg_Vertices[1].y = 0.5;	tg_Vertices[1].z = 0.0f;
	tg_Vertices[2].x = -0.5; tg_Vertices[2].y = -0.5;	tg_Vertices[2].z = 0.0f;
	tg_Vertices[3].x = 0.5;  tg_Vertices[3].y = -0.5;	tg_Vertices[3].z = 0.0f;
	
	
	tg_Vertices[0].color= PG1_COLOR_RGB(255,0,0);
	tg_Vertices[1].color= PG1_COLOR_RGB(255,0,0);
	tg_Vertices[2].color= PG1_COLOR_RGB(255,0,0);
	tg_Vertices[3].color= PG1_COLOR_RGB(255,0,0);

	updateLocalTransformation();
}

Quad::~Quad(){
	delete m_pkTransformationMatrix;
	m_pkTransformationMatrix= NULL;

	delete[] tg_Vertices;
	tg_Vertices = NULL;
}

void pg1::Quad::draw(Renderer& renderer) const{

	renderer.setMatrix(World,m_pkTransformationMatrix);
	renderer.Draw(tg_Vertices, TriangleStrip, 4);
}